package com.xyz.apis.repository;

import com.xyz.admin.common.global.EvTicketRedisKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by liuwei on 2019-07-06 13:15:27
 */

@Service
public class RedisRepository {

    private static final Logger logger = LoggerFactory.getLogger(RedisRepository.class);

    @Autowired
    private JedisService jedisService;


    public  String getValue(String  key){
        try{
            String value = jedisService.hget(EvTicketRedisKey.sys_dictionary_key, key);
            return value;
        }catch (Exception e){
            logger.error("ProfitConfig error: key is null:{}",key);
        }
        return "";
    }

    public  String getVersionValue(){
        try{
            String value = jedisService.get("ticketapi_appversion");
            return value;
        }catch (Exception e){
            logger.error("ProfitConfig error: key is null:{}","ticketapi_appversion");
        }
        return "";
    }

    public  String getPcVersionValue(){
        try{
            String value = jedisService.get("ticketapi_pcversion");
            return value;
        }catch (Exception e){
            logger.error("ProfitConfig error: key is null:{}","ticketapi_appversion");
        }
        return "";
    }



    public  Boolean setQRCodeValue(String key,String value){
        try{
            jedisService.set(EvTicketRedisKey.QRCode.concat(":info:").concat(key),  value, 120);
        }catch (Exception e){
            logger.error("ProfitConfig error: key is null:{}",key);
            return false;
        }
        return true;
    }

    public  String getQRCodeValue(String  key){
        try{
            String value = jedisService.get(EvTicketRedisKey.QRCode.concat(":info:").concat(key));
            return value;
        }catch (Exception e){
            logger.error("ProfitConfig error: key is null:{}",key);
        }
        return "";
    }



}
